/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package springapp.web;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import springapp.domain.Product;
import springapp.respository.ProductDao;

/**
 *
 * @author john
 */
public class HelloController implements Controller {
    private ProductDao productDao;

    public void setProductDao(ProductDao productDao) {
        this.productDao = productDao;
    }
    @Override
    public ModelAndView handleRequest(HttpServletRequest hsr, HttpServletResponse hsr1) throws Exception {
        List<Product> products = productDao .getProductList();
        Map<String, Object> myModel = new HashMap<String, Object>();        
        myModel.put("products", products);
        return new ModelAndView("hello", "model", myModel);
    }

   

}
